package com.java8;

import com.java8.testInterface.MyInterface;
import com.java8.testInterface.impl.MyInterfaceImpl;
import org.junit.Test;

import java.util.Comparator;

/**
 *
 * Lambda表达式的使用举例
 *
 * @author: 临晖
 * @date: 2024/03/22
 * @description:
 */


public class LambdaTest {

    @Test
    public void test1() {
        Runnable r1 = () -> System.out.println("我爱北京天安门");

        r1.run();
    }

    @Test
    public void test2() {
        Comparator<Integer> com = (o1, o2) ->  Integer.compare(o1, o2);
        Comparator<Integer> com2 =  Integer::compare;
        com.compare(32, 31);
    }


    @Test
    public void test3() {
        MyInterface sum = new MyInterfaceImpl():: sum;
        MyInterface sum1 = Integer :: sum;
        MyInterface sum2 = (a, b) -> Integer.sum(a, b);

        System.out.println(sum.sum(1, 2));


    }
}
